<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div th:include="back/common/cssjs :: main"></div>

<div class="container">
    <div class="mt-3">
        <h3 class="text-center">商品列表</h3>
        <div class="mt-3 mb-3">
            <a href="javascript:" onclick="add()" class="btn btn-success">商品上架</a>
        </div>
        <script>
            function add() {
                var index = layer.open({
                    type: 2, title: "呵呵",
                    area: ['600px', '500px'],
                    content: "add",
                    maxmin: true
                });
                layer.full(index);
            }
        </script>

        <table class="table table-bordered">
            <tr>
                <th>ID</th>
                <th>商品名</th>
                <th>价格</th>
                <th>操作</th>
            </tr>
            <tr th:each="one:${ProductList}">
                <td th:text="${one.id}"></td>
                <td th:text="${one.name}"></td>
                <td th:text="${one.price}"></td>
                <td>
                    <a th:href="'edit?id='+ ${one.id}" class="btn btn-warning btn-sm">修改</a>
                    <a th:onclick="|del(${one.id})|" href="javascript:void(0)" class="btn btn-danger btn-sm">下架</a>
                </td>
            </tr>
        </table>
    </div>
</div>
<script>
    function del(id) {
        if (confirm("你真的要删除吗？")) {
            location.href = "del?id=" + id;
        }
    }
</script>

</body>
</html>